home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2000 / MacHack 2000.toast / pc / The Hacks / MacHacksBug / Python 1.5.2c1 / Lib / test / test_rgbimg.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2000-06-23  |  1.9 KB  |  61 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 1.5)
  3.  
  4. import rgbimg
  5. import os
  6. import uu
  7. findfile
  8. error = 'test_rgbimg.error'
  9. print 'RGBimg test suite:'
  10.  
  11. def testimg(rgb_file, raw_file):
  12.     rgb_file = findfile(rgb_file)
  13.     raw_file = findfile(raw_file)
  14.     (width, height) = rgbimg.sizeofimage(rgb_file)
  15.     rgb = rgbimg.longimagedata(rgb_file)
  16.     if len(rgb) != width * height * 4:
  17.         raise error, 'bad image length'
  18.     
  19.     raw = open(raw_file, 'rb').read()
  20.     if rgb != raw:
  21.         raise error, "images don't match for " + rgb_file + ' and ' + raw_file
  22.     
  23.     for depth in [
  24.         1,
  25.         3,
  26.         4]:
  27.         rgbimg.longstoimage(rgb, width, height, depth, '@.rgb')
  28.     
  29.     os.unlink('@.rgb')
  30.  
  31. table = [
  32.     ('testrgb.uue', 'test.rgb'),
  33.     ('testimg.uue', 'test.rawimg'),
  34.     ('testimgr.uue', 'test.rawimg.rev')]
  35. for source, target in table:
  36.     source = findfile(source)
  37.     target = findfile(target)
  38.     uu.decode(source, target)
  39.  
  40. ttob = rgbimg.ttob(0)
  41. if ttob != 0:
  42.     raise error, 'ttob should start out as zero'
  43.  
  44. testimg('test.rgb', 'test.rawimg')
  45. ttob = rgbimg.ttob(1)
  46. if ttob != 0:
  47.     raise error, 'ttob should be zero'
  48.  
  49. testimg('test.rgb', 'test.rawimg.rev')
  50. ttob = rgbimg.ttob(0)
  51. if ttob != 1:
  52.     raise error, 'ttob should be one'
  53.  
  54. ttob = rgbimg.ttob(0)
  55. if ttob != 0:
  56.     raise error, 'ttob should be zero'
  57.  
  58. for source, target in table:
  59.     unlink(findfile(target))
  60.  
  61.